#ifndef __CTNODE_H__
#define __CTNODE_H__

#ifndef NULL
# define NULL ((void *)0)
#endif

typedef enum
{
  TempoElement = 0,
  BeatsElement,
  AccentLevelElement,
  QuarterLevelElement,
  EighthLevelElement,
  SixteenthLevelElement,
  TripletLevelElement,
  MeasureElement,
  RepeatBeginElement,
  RepeatEndElement,
  AccelElement,
  DecelElement,
  NumberElements
} CTElement;

typedef struct _CTNode
{
  CTElement type;
  int value;
  struct _CTNode *partner;
  struct _CTNode *next;
} CTNode;

typedef struct _CTList
{
  CTNode *head;
  CTNode *tail;
} CTList;

typedef void (*ctnode_callback)(CTNode *, void *);

/* Allocates a new CTNode */
void ctlist_create (CTList *list);

/* Calls callback (node, data) for each node in list */
void ctlist_forall (CTList *list, ctnode_callback callback, void *data);

/* Appends node onto end of list */
void ctlist_append_node (CTList *list, CTNode *node);

/* Prepends node to the beginning of list */
void ctlist_prepend_node (CTList *list, CTNode *node);

/* Removes node from list */
void ctlist_remove_node (CTList *list, CTNode *node);

#endif
